package com.ljkj.zjf.common;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Date;

public class MeterInitTools {

	// ����
	final public static int ADD = 0;
	// ����
	final public static int UPDATE = 1;
	// ɾ��
	final public static int DELETE = 2;
	
	//hisvo��Ҫ���ֶΣ���ʱд������
	final public static String HIS_OPRID = "lyz" ;
	final public static String HIS_OPRORG = "zhshch" ;
	final public static String HIS_OPRADDR = "nll" ;
	
	
	/**
	 * ��õ�ǰʱ��
	 * @return
	 */
	public static Date getDate(){
		return new Date() ;
	}

	/**
	 * �����쳣��Ϣ����ջ�����ڴ�ӡ��־
	 * 
	 * @param e
	 * @return
	 */
	public static String getStackData(Exception e) {
		StringWriter sw = null;
		PrintWriter pw = null;

		sw = new StringWriter();
		pw = new PrintWriter(sw);
		// �������ջ��Ϣ�����printWriter��
		e.printStackTrace(pw);
		pw.flush();
		sw.flush();

		if (sw != null) {
			try {
				sw.close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
		if (pw != null) {
			pw.close();
		}

		return sw.toString();
	}
	
	/**
	 * ���������ַ���ʽ�磺"/p1=value1/p2=value2/.../"
	 * @param separator String �ָ�����"/"
	 * @param totalStr String �����ַ�
	 * @param resultPara String �������ʽ��"/p1="
	 * @return String ����ֵ
	 */
	public static String parseStringPara(String separator,String totalStr,String para){
	    int beginsite = totalStr.indexOf(para);
	    if(beginsite == -1) return null;
	    beginsite += para.length();
	    int endsite = totalStr.indexOf(separator,beginsite);
	    String paraValue = totalStr.substring(beginsite,endsite);
	    return paraValue;
	}

}
